package Framework;





import javax.swing.*;
/*
 * Severity:
 * 10: Debug Level 1 - Very verbose messages from UI
 * 20: Debug Level 2 - Slightly less verbose messages from UI
 * 30: Debug Level 3 - Developer level messages for testing
 * 40: Hardware - Input/Output notification from Hardware window 
 * 
 * 100:	Fatal - Messages which are fatal.
 * 
 */

public class debugMessage {
	static JTextArea	mle_textArea = null;
	static int			ii_indentCount = 0;
	// Registers mle_textArea, any debug messages now go there.
	public static void mleRegister(JTextArea amle_textArea){
		mle_textArea = amle_textArea;
	}

	// Sends a message to the debug screen if ai_Severity is more than debugOpts.DEBUG_LEVEL
	// See mleRegister above to redirect, instead of console..
	public static void log(String as_Message, int ai_Severity){
		if (ai_Severity >= ConfigOpts.DEBUG_LEVEL){
			if (mle_textArea == null){
				System.out.println(as_Message);
			} else {
				System.out.println(ai_Severity + "  " + as_Message);
				mle_textArea.append(as_Message + "\n");
				// Setting mle line to last message.
				mle_textArea.setCaretPosition(mle_textArea.getText().length() - 1);
			}
		}
		
	}
	
	/* Test Driver */ 
	/* OBSOLETE. Does not try to use mle_textArea at all...
	 *	
	public static void main(String[] args) {
		debugMessage debug_TestDriver = new debugMessage();
		
		debug_TestDriver.log("Hello World, 0", 0);
		debug_TestDriver.log("Hello World, 10", 10);
		debug_TestDriver.log("Hello World, 9", 9);
		debug_TestDriver.log("Hello World, 11", 11);
		

	}
	*/

}
